<?php
/**
 * Created by PhpStorm.
 * User: LiuTao
 * Date: 2018/11/12
 * Time: 17:50
 */

$port = 14446;
$group_ip = '228.5.6.7';
// $group_ip = "228.5.6.8"; //different ip
$group_params = array(
    "group" => $group_ip,
    "interface" => 0
);

$send_msg = "hello , i am multicast server";
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);

socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP, $group_params);
socket_sendto($socket, $send_msg, strlen($send_msg), 0, $group_ip, $port);
socket_close($socket);
